import { ProductCategory2Type, ProductCategory3Type } from '/@/util/product-type';

import { DataTimeSelectEnum, DataTimeListEnum } from '/@/enums/productEnum';

export const ForcastList: ProductCategory2Type[] = [
  {
    category1: 'forcast',
    category2: 'forcast-szfjybjy',
    label: '数值分级预报检验',
    title: '数值分级预报检验',
    defaultItemKey: 'szfj#dust_ens#03',
  },
];

export const ProductList: ProductCategory3Type[] = [
  {
    category1: 'forcast',
    category2: 'forcast-szfjybjy',
    itemKey: 'szfj#dust_ens#03',
    label: '3小时',
    title: '3小时',
    dataTimeSelectType: DataTimeSelectEnum.HOURS,
    dataTimeListType: DataTimeListEnum.HOUR_LIST,
  },
  {
    category1: 'forcast',
    category2: 'forcast-szfjybjy',
    itemKey: 'szfj#dust_ens#24',
    label: '24小时',
    title: '24小时',
    dataTimeSelectType: DataTimeSelectEnum.HOURS,
    dataTimeListType: DataTimeListEnum.HOUR_LIST,
  },
];

export const getProductList12 = (category1: string, category2: string, size: number) => {
  const results: ProductCategory3Type[] = [];
  for (const item in ProductList) {
    if (size > 0 && results.length >= size) {
      return results;
    }
    if (ProductList[item].category1 == category1 && ProductList[item].category2 == category2) {
      results.push(ProductList[item]);
    }
  }
  return results;
};

export const getProductList1 = (category1: string, size: number) => {
  const results: ProductCategory3Type[] = [];
  for (const item in ProductList) {
    if (size > 0 && results.length >= size) {
      return results;
    }
    if (ProductList[item].category1 == category1) {
      results.push(ProductList[item]);
    }
  }
  return results;
};

export const getProductByItemKey = (itemKey: string) => {
  for (const i in ProductList) {
    if (ProductList[i].itemKey === itemKey) {
      return ProductList[i];
    }
  }
};
